const listBox = document.querySelector('.notice');
listBox.innerHTML += listBox.innerHTML;
listBox.scrollTop = 0;
const itemHeight = 35;  // li 高度
const delay = 2000; // timeout 时长
const speed = 50; // iterval 时长
let timer; // 保存 iterval 引用
let counter = 0;



function init() {
    timer = setInterval(slide, speed);
    listBox.scrollTop = ++counter; // 先滚一点, 避免一直停在 counter % itemHeight == 0
}

function slide() {  // 滚动逻辑
    if (counter % itemHeight === 0) {
        clearInterval(timer);
        setTimeout(init, delay)
    } else {
        listBox.scrollTop = ++counter;
        if (listBox.scrollTop >= listBox.scrollHeight / 2) {
            counter = 0;
            listBox.scrollTop = counter;
        }
    }
}
setTimeout(init, delay)